<%--
 *  File:    AdvancedFilter.jsp
 *  @Author: banshang
 *  Date:    2010/09/17
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "IMG";
 	String strTableName = "v_advancedfilter";
	String privilegeCode = "Z0831";    
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>AdvancedFilter</title>
<PageFlow:CheckPageFlow pageName="p_advancedfilter"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
  	if(totalsummary == null)
  	{
  		totalsummary = new Vector();
  	}
%>

<script language="JavaScript" >
function page_summary(actionvalue,orderbyname){
  	 var editform = summaryPrepare(cform,actionvalue,orderbyname);
 	 editform.action = "AdvancedFilter.jsp?<%= OvalTools.randomURL() %>";
 	 editform.target = "_self";
 	 isRunning = true;
 	 editform.submit();
}

function page_add(){
	if(isEmpty(document.cform.analyzecodeid.value))
	{
       alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_AnalyzeCode",false)) %>");
       return;
	}
	
	if(isEmpty(document.cform.filtername.value))
	{
       alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_ConditionName",false)) %>");
       return;
	}
	
	if(isEmpty(document.cform.script.value))
	{
       alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Condition",false)) %>");
       return;
	}
	 cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_save(){
     if(!checkForm(cform)) return;
	 cform.actionname.value = "save";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
<input type="hidden" name="pagename" value="p_advancedfilter">
<input type="hidden" name="actionname">
<custom:hidden name="userinfo" property="orgid" scope="session"/>
<custom:hidden name="userinfo" property="userid" changedName="maker" scope="session"/>

<input type="hidden" name="numrows" value="<%=JspHelper.filterNull( totalsummary.size() )%>">

<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr> 
     	<td>
         	<%= label.getLabelName("L_ConditionType") + label.getLabelName("L_Colon") %>
			<custom:selectdic name="searchqlparams" property="filtertype" dictType="FilterType" />
			&nbsp;&nbsp;
         	<a href="javascript:page_summary('search')"><img src="<%= ConstantProp.DEFAULT_ROOT_PATH %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a></td>
         </td>
  </tr>
</table>
<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left" >
		  <td width="26" class="title_center">&nbsp;</td>
          <td width="180" class="title_center"><a href="javascript:page_summary('orderby','analyzecode')"><%= label.getLabelName("L_AnalyzeCode") %></a>&nbsp;<span class='red'>*</span></td>
          <td class="title_center" width="295"><a href="javascript:page_summary('orderby','analyzecodename')"><%= label.getLabelName("L_AnalyzeCodeName") %></a></td>
          <td class="title_center" width="300"><a href="javascript:page_summary('orderby','filtername')"><%= label.getLabelName("L_ConditionName") %></a>&nbsp;<span class='red'>*</span></td>
          <td class="title_center" width="200"><a href="javascript:page_summary('orderby','script')"><%= label.getLabelName("L_Condition") %></a>&nbsp;<span class='red'>*</span></td>
        </tr>
		 <% //--------------------------------------  default value definition --%>
          	<%
            	int i = 0;
             	String strClassType = new String();
          	%>

          	<% //--------------------------------------  loop results --%>
		<logic:iterate id="onerow" collection="<%= totalsummary %>" indexId="idx">
           	<%
            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "";
            	}
            	i++;
          	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
          		<td width="5">
              		<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("advancedfilterid") )%>" class="checkbox">
            	</td>
            	<td><custom:write name="onerow" property="analyzecode" /></td>
            	<td><custom:write name="onerow" property="analyzecodename" /></td>
				<td><custom:text name="onerow" property="filtername" size="40" command="notnull" label="L_ConditionName" colIndex="<%= idx %>"/></td>    
				<td>
				    <custom:text name="onerow" property="script" size="40" command="notnull" label="L_Condition" colIndex="<%= idx %>"/> 
     		        <custom:hidden name="onerow" property="advancedfilterid" colIndex="<%= idx %>"/>
     		    </td>
     		 </tr>
     	 </logic:iterate>
      <tr class="none">
            <td>&nbsp;</td>
            <td><custom:select property="analyzecodeidtosel" changedName="analyzecodeid" optionsName="allanalyzecode"  optionValueKey="analyzecodeidtosel" optionInnerTextKey="analyzecodenames" defaultValue="--------" defaultValueCost=" " /></td>
            <td>&nbsp;</td>
            <td><input type="text" name="filtername" size="40"></td>
            <td><input type="text" name="script" size="40"></td>
      </tr>
       <%@ include file="/inc/SummaryAction.inc" %>
     <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top"></td>
        </tr>
        <tr>
          <td class="td_center">
		  	<a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a> 
		  	<a onclick="page_save()"><custom:button type="1" label="L_Save" imgsrc="save.gif" border="0" style="width:60"/></a> 
		  	<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
		  </td>
        </tr>
     </table>
</table>
</form>
</body>
</html>



